{extend name="$_admin_base_layout" /}

{block name="plugins-css"}
<link href="__LIBS__/jstree/themes/default/style.min.css" rel="stylesheet" />
<!--加载CSS的地方-->
<style type="text/css">
    .box {
        position: relative;
        min-height: 650px;
        width: 100%;
        margin: 0 auto;
    }

    .gdxx {
        padding: 1%;
        position: absolute;
        display: inline-block;
        background-color: white;
        z-index: 999;
        top: 240px;
        height: 180px;
        width: 180px;
        margin-left: -200px;
        border-radius: 6px;
        box-shadow: 0px 2px 13px 0px rgba(0, 67, 101, 0.08);
    }

    .bh {
        font-size: 15px;
        color: black;
        height: 30px;
        margin-top: 6px;
    }

    .bh input {
        text-align: center;
        margin-top: 10px;
    }

    .add,
    .stop {
        margin-top: 60px;
        background-color: rgb(68, 172, 233);
        border: 0;
        border-radius: 3px;
        text-align: center;
        height: 25px;
        line-height: 25px;
        width: 70px;
        color: white;
    }
</style>
{/block}

{block name="content"}
{notempty name="page_tips"}
<div class="alert alert-{$tips_type|default='info'} alert-dismissable">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
    <p>{$page_tips|raw|default=''}</p>
</div>
{/notempty}
<div class="row">
    <div class="col-md-12">
        <input type="hidden" id="business_id" value="{$business_id}">
        <div class="block">
            <ul class="nav nav-tabs">
                {volist name="tab_nav['tab_list']" id="vo"}
                <li {eq name="tab_nav.curr_tab" value="$key" }class="active" {/eq}> <a href="{$vo.url}?_pop=1">
                    {$vo.title}</a>
                </li>
                {/volist}
                <li class="pull-right">
                    <ul class="block-options push-10-t push-10-r">
                        <li>
                            <button id="lng" type="button" class="page-reload"><i class="si si-refresh"></i></button>
                        </li>
                        <li>
                            <button id="lat" type="button" data-toggle="block-option"
                                data-action="fullscreen_toggle"></button>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="col-md-12">
        <!--写地图内容的地方-->
        <div>
            <div>公司名称：
                <select name="" id="business_id" onclick="select_event1(this.options[this.selectedIndex].value);">
                    <option value="mapselect" selected>请选择公司</option>
                    <option value="listselect">无设备公司A</option>
                    <option value="listselect1">无设备公司B</option>

                </select>
                <select id="company1" style="display: none;"
                    onclick="select_event2(this.options[this.selectedIndex].value);">
                    <option selected>请选择</option>
                    <option value="line1">ENAQA1</option>
                    <option value="line2">ENAQA2</option>
                </select>
                <select id="company2" style="display: none;"
                    onclick="select_event3(this.options[this.selectedIndex].value);">
                    <option selected>请选择</option>
                    <option value="line11">ENQB1</option>
                    <option value="line22">ENQB2</option>
                </select>
                <div class="gdxx">
                    <div class="bh">
                        管道编号：<input id="code" type="text" value="" style="width: 70px;">
                    </div>
                    <div class="bh">
                        经度：<input id="jd" type="text" value="" style="width:90px;"><br>
                        纬度：<input id="wd" type="text" value="" style="width: 90px;">
                    </div>
                </div>
            </div>
            起始位置：<input type="text" name="beginPos">
            结束位置：<input type="text" name="endPos">
            <input type="button" name="getPoint" value="获取位置">
            距离为：<input type="text" name="distance" readonly="readonly">
            <span id="msg">正在获取当前位置...</span>
            <div class="box" id="map1"></div>
            <div class="box" id="map2" style="display: none;"></div>
            <div class="box" id="map3" style="display: none;"></div>
            <div class="box" id="map4" style="display: none;"></div>
            <div class="box" id="map5" style="display: none;"></div>
        </div>
    </div>
    {/block}
    {block name="script"}
    <!--写JS和加载的地方-->
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=uPaROIYtjmX7yKEA1WjzDbOR9DyEem6k">
    </script>
    <script>
        function select_event1(value) {
            //一级菜单
            document.getElementById("map1").style.display = "none";
            document.getElementById("map2").style.display = "none";
            document.getElementById("map3").style.display = "none";
            document.getElementById("map4").style.display = "none";
            document.getElementById("map5").style.display = "none";
            //二级菜单
            document.getElementById("company1").style.display = "none";
            document.getElementById("company2").style.display = "none";
            if (value === "mapselect") {
                document.getElementById("map1").style.display = "";
            } else if (value === "listselect") {
                document.getElementById("company1").style.display = "";
                document.getElementById("map1").style.display = "";
            } else if (value === "listselect1") {
                document.getElementById("company2").style.display = "";
                document.getElementById("map1").style.display = "";
            }
        }

        function select_event2(value) {
            document.getElementById("map1").style.display = "none";
            document.getElementById("map2").style.display = "none";
            document.getElementById("map3").style.display = "none";
            document.getElementById("map4").style.display = "none";
            document.getElementById("map5").style.display = "none";
            if (value === "line1") {
                document.getElementById("map2").style.display = "";
            } else if (value === "line2") {
                document.getElementById("map3").style.display = "";
            }
        }

        function select_event3(value) {
            document.getElementById("map1").style.display = "none";
            document.getElementById("map2").style.display = "none";
            document.getElementById("map3").style.display = "none";
            document.getElementById("map4").style.display = "none";
            document.getElementById("map5").style.display = "none";
            if (value === "line11") {
                document.getElementById("map4").style.display = "";
            } else if (value === "line22") {
                document.getElementById("map5").style.display = "";
            }
        }
    </script>
    <!-- 未选中状态 -->
    <script type="text/javascript">
        //创建和初始化地图函数：
        function initMap() {
            createMap(); //创建地图
            setMapEvent(); //设置地图事件
            addMapControl(); //向地图添加控件
            addMapOverlay(); //向地图添加覆盖物
            addMarker(points);
        }

        function createMap() {
            map = new BMap.Map("map1");
            map.centerAndZoom(new BMap.Point(104.050791, 30.689824), 19);
            map.enableScrollWheelZoom(true);
            //点击获取坐标值在左侧信息框中显示
            var x;
            var y;
            map.addEventListener("click", function (e) {
                var point = new BMap.Point(e.point.lng, e.point.lat);
                addMarker(point);
                x = e.point.lng;
                y = e.point.lat;
                console.log(e.point.lng + "," + e.point.lat); //获取坐标值
                document.getElementById('jd').value = e.point.lng;
                document.getElementById('wd').value = e.point.lat;
            });
            //地图上的连线
            var polyline = new BMap.Polyline([
                new BMap.Point(104.04990080769804, 30.689783803755507),
                new BMap.Point(104.04990515032924, 30.689788130646633),
                new BMap.Point(104.0499143795186, 30.68979542655525),
                new BMap.Point(104.18772259340373, 30.691270917568072),
                new BMap.Point(104.18772640730262, 30.69127194677355)
            ], {
                strokeColor: 'blue',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            var polyline2 = new BMap.Polyline([
                new BMap.Point(104.0772341217574, 30.691265209426035),
                new BMap.Point(104.18772450193988, 30.69126519348827),
                new BMap.Point(104.18773259884, 30.69125197472752),
                new BMap.Point(104.18772395712683, 30.6912649360128),
                new BMap.Point(104.183368427163, 30.6917656167707)
            ], {
                strokeColor: 'red',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            var polyline3 = new BMap.Polyline([
                new BMap.Point(104.050774, 30.68867),
                new BMap.Point(104.050196, 30.689533),
                new BMap.Point(104.052786, 30.689546)

            ], {
                strokeColor: 'green',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            map.addOverlay(polyline);
            map.addOverlay(polyline2);
            map.addOverlay(polyline3);
        }

        function setMapEvent() {
            map.enableScrollWheelZoom();
            map.enableKeyboard();
            map.enableDragging();
            map.enableDoubleClickZoom();
        }

        function addClickHandler(target, window) {
            target.addEventListener("click", function () {
                target.openInfoWindow(window);
            });
        }

        function addMapOverlay() {
            var markers = [{
                title: "乐度软件",
                imageOffset: {
                    width: 0,
                    height: 3
                },
                position: {
                    lat: 30.689711,
                    lng: 104.050279
                }
            }];
            for (var index = 0; index < markers.length; index++) {
                var point = new BMap.Point(markers[index].position.lng, markers[index].position.lat);
                var marker = new BMap.Marker(point, {
                    icon: new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png", new BMap
                        .Size(20, 25), {
                            imageOffset: new BMap.Size(markers[index].imageOffset.width, markers[index]
                                .imageOffset.height)
                        })
                });
                var label = new BMap.Label(markers[index].title, {
                    offset: new BMap.Size(25, 5)
                });
                var opts = {
                    width: 200,
                    title: markers[index].title,
                    enableMessage: false
                };
                var infoWindow = new BMap.InfoWindow(markers[index].content, opts);
                marker.setLabel(label);
                addClickHandler(marker, infoWindow);
                map.addOverlay(marker);
            };
        }
        //地图上的点
        var points = [{
                "lng": 104.04990080769804,
                "lat": 30.689783803755507,
                "id": 1,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.04990515032924,
                "lat": 30.689788130646633,
                "id": 2,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.0499143795186,
                "lat": 30.68979542655525,
                "id": 3,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772259340373,
                "lat": 30.691270917568072,
                "id": 4,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772640730262,
                "lat": 30.69127194677355,
                "id": 5,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.0772341217574,
                "lat": 30.691265209426035,
                "id": 1,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772450193988,
                "lat": 30.69126519348827,
                "id": 2,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18773259884,
                "lat": 30.69125197472752,
                "id": 3,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772395712683,
                "lat": 30.6912649360128,
                "id": 4,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.183368427163,
                "lat": 30.6917656167707,
                "id": 5,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.050774,
                "lat": 30.68867,
                "id": 1,
                "name": "NEQB1",
                "company": "无设备公司B"
            },
            {
                "lng": 104.050196,
                "lat": 30.689533,
                "id": 2,
                "name": "NEQB1",
                "company": "无设备公司B"
            },
            {
                "lng": 104.052786,
                "lat": 30.689546,
                "id": 3,
                "name": "NEQB1",
                "company": "无设备公司B"
            }

        ];
        //创建标注点添加到地图中
        function addMarker(points) {
            //循环建立标注点
            for (var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
                var marker = new BMap.Marker(point); //将点转化成标注点
                map.addOverlay(marker); //将标注点添加到地图上
                //添加监听事件
                (function () {
                    var thePoint = points[i];
                    marker.addEventListener("click",
                        function () {
                            showInfo(this, thePoint);
                        });
                })();
            }
        }

        function showInfo(thisMarker, point) {
            //获取点的信息
            var sContent =
                '<ul style="margin:0 0 5px 0;padding:0.2em 0">' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">id：</span>' + point.id + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">编号：</span>' + point.name + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 80px;display: inline-block;">公司名称：</span>' + point.company + '</li>' +
                '</ul>';
            document.getElementById('code').value = point.name;
            var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
            thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
        }
        //向地图添加控件
        function addMapControl() {
            var scaleControl = new BMap.ScaleControl({
                anchor: BMAP_ANCHOR_BOTTOM_LEFT
            });
            scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
            map.addControl(scaleControl);
            var navControl = new BMap.NavigationControl({
                anchor: BMAP_ANCHOR_TOP_LEFT,
                type: BMAP_NAVIGATION_CONTROL_LARGE
            });
            map.addControl(navControl);
            var overviewControl = new BMap.OverviewMapControl({
                anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                isOpen: true
            });
            map.addControl(overviewControl);
        }
        var map;
        initMap();
    </script>

    <!-- 无设备公司A 管道1-->
    <script type="text/javascript">
        //创建和初始化地图函数：
        function initMap() {
            createMap(); //创建地图
            setMapEvent(); //设置地图事件
            addMapControl(); //向地图添加控件
            addMapOverlay(); //向地图添加覆盖物
            addMarker(points);
        }

        function createMap() {
            map = new BMap.Map("map2");
            map.centerAndZoom(new BMap.Point(104.050791, 30.689824), 19);
            map.enableScrollWheelZoom(true);

            //点击获取坐标值
            var x;
            var y;
            map.addEventListener("click", function (e) {
                var point = new BMap.Point(e.point.lng, e.point.lat);
                addMarker(point);
                x = e.point.lng;
                y = e.point.lat;
                console.log(e.point.lng + "," + e.point.lat); //获取坐标值
                document.getElementById('jd').value = e.point.lng;
                document.getElementById('wd').value = e.point.lat;
            });
            //地图上的连线
            var polyline = new BMap.Polyline([
                new BMap.Point(104.04990080769804, 30.689783803755507),
                new BMap.Point(104.04990515032924, 30.689788130646633),
                new BMap.Point(104.0499143795186, 30.68979542655525),
                new BMap.Point(104.18772259340373, 30.691270917568072),
                new BMap.Point(104.18772640730262, 30.69127194677355)
            ], {
                strokeColor: 'blue',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            map.addOverlay(polyline);
        }

        function setMapEvent() {
            map.enableScrollWheelZoom();
            map.enableKeyboard();
            map.enableDragging();
            map.enableDoubleClickZoom();
        }

        function addClickHandler(target, window) {
            target.addEventListener("click", function () {
                target.openInfoWindow(window);
            });
        }

        function addMapOverlay() {
            var markers = [{
                title: "乐度软件",
                imageOffset: {
                    width: 0,
                    height: 3
                },
                position: {
                    lat: 30.689711,
                    lng: 104.050279
                }
            }];
            for (var index = 0; index < markers.length; index++) {
                var point = new BMap.Point(markers[index].position.lng, markers[index].position.lat);
                var marker = new BMap.Marker(point, {
                    icon: new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png", new BMap
                        .Size(20, 25), {
                            imageOffset: new BMap.Size(markers[index].imageOffset.width, markers[index]
                                .imageOffset.height)
                        })
                });
                var label = new BMap.Label(markers[index].title, {
                    offset: new BMap.Size(25, 5)
                });
                var opts = {
                    width: 200,
                    title: markers[index].title,
                    enableMessage: false
                };
                var infoWindow = new BMap.InfoWindow(markers[index].content, opts);
                marker.setLabel(label);
                addClickHandler(marker, infoWindow);
                map.addOverlay(marker);
            };
        }
        //地图上的点
        var points = [{
                "lng": 104.04990080769804,
                "lat": 30.689783803755507,
                "id": 1,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.04990515032924,
                "lat": 30.689788130646633,
                "id": 2,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.0499143795186,
                "lat": 30.68979542655525,
                "id": 3,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772259340373,
                "lat": 30.691270917568072,
                "id": 4,
                "name": "NOEQA1",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772640730262,
                "lat": 30.69127194677355,
                "id": 5,
                "name": "NOEQA1",
                "company": "无设备公司A"
            }
        ];
        //创建标注点添加到地图中
        function addMarker(points) {
            //循环建立标注点
            for (var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
                var marker = new BMap.Marker(point); //将点转化成标注点
                map.addOverlay(marker); //将标注点添加到地图上
                //添加监听事件
                (function () {
                    var thePoint = points[i];
                    marker.addEventListener("click",
                        function () {
                            showInfo(this, thePoint);
                        });
                })();
            }
        }

        function showInfo(thisMarker, point) {
            //获取点的信息
            var sContent =
                '<ul style="margin:0 0 5px 0;padding:0.2em 0">' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">id：</span>' + point.id + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">编号：</span>' + point.name + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 80px;display: inline-block;">公司名称：</span>' + point.company + '</li>' +
                '</ul>';
            document.getElementById('code').value = point.name;
            var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
            thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
        }
        //向地图添加控件
        function addMapControl() {
            var scaleControl = new BMap.ScaleControl({
                anchor: BMAP_ANCHOR_BOTTOM_LEFT
            });
            scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
            map.addControl(scaleControl);
            var navControl = new BMap.NavigationControl({
                anchor: BMAP_ANCHOR_TOP_LEFT,
                type: BMAP_NAVIGATION_CONTROL_LARGE
            });
            map.addControl(navControl);
            var overviewControl = new BMap.OverviewMapControl({
                anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                isOpen: true
            });
            map.addControl(overviewControl);
        }
        var map;
        initMap();
    </script>
    <!-- 无设备公司A 管道2-->
    <script type="text/javascript">
        //创建和初始化地图函数：
        function initMap() {
            createMap(); //创建地图
            setMapEvent(); //设置地图事件
            addMapControl(); //向地图添加控件
            addMapOverlay(); //向地图添加覆盖物
            addMarker(points);
            // openEdit();
            // closeEdit();
        }

        function createMap() {
            map = new BMap.Map("map3");
            map.centerAndZoom(new BMap.Point(104.050791, 30.689824), 19);
            map.enableScrollWheelZoom(true);

            //点击获取坐标值
            var x;
            var y;
            map.addEventListener("click", function (e) {
                var point = new BMap.Point(e.point.lng, e.point.lat);
                addMarker(point);
                x = e.point.lng;
                y = e.point.lat;
                console.log(e.point.lng + "," + e.point.lat); //获取坐标值
                document.getElementById('jd').value = e.point.lng;
                document.getElementById('wd').value = e.point.lat;
            });
            //地图上的连线
            var polyline2 = new BMap.Polyline([
                new BMap.Point(104.0772341217574, 30.691265209426035),
                new BMap.Point(104.18772450193988, 30.69126519348827),
                new BMap.Point(104.18773259884, 30.69125197472752),
                new BMap.Point(104.18772395712683, 30.6912649360128),
                new BMap.Point(104.183368427163, 30.6917656167707)
            ], {
                strokeColor: 'red',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            map.addOverlay(polyline2);
        }

        function setMapEvent() {
            map.enableScrollWheelZoom();
            map.enableKeyboard();
            map.enableDragging();
            map.enableDoubleClickZoom();
        }

        function addClickHandler(target, window) {
            target.addEventListener("click", function () {
                target.openInfoWindow(window);
            });
        }

        function addMapOverlay() {
            var markers = [{
                title: "乐度软件",
                imageOffset: {
                    width: 0,
                    height: 3
                },
                position: {
                    lat: 30.689711,
                    lng: 104.050279
                }
            }];
            for (var index = 0; index < markers.length; index++) {
                var point = new BMap.Point(markers[index].position.lng, markers[index].position.lat);
                var marker = new BMap.Marker(point, {
                    icon: new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png", new BMap
                        .Size(20, 25), {
                            imageOffset: new BMap.Size(markers[index].imageOffset.width, markers[index]
                                .imageOffset.height)
                        })
                });
                var label = new BMap.Label(markers[index].title, {
                    offset: new BMap.Size(25, 5)
                });
                var opts = {
                    width: 200,
                    title: markers[index].title,
                    enableMessage: false
                };
                var infoWindow = new BMap.InfoWindow(markers[index].content, opts);
                marker.setLabel(label);
                addClickHandler(marker, infoWindow);
                map.addOverlay(marker);
            };
        }
        //地图上的点
        var points = [{
                "lng": 104.0772341217574,
                "lat": 30.691265209426035,
                "id": 1,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772450193988,
                "lat": 30.69126519348827,
                "id": 2,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18773259884,
                "lat": 30.69125197472752,
                "id": 3,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.18772395712683,
                "lat": 30.6912649360128,
                "id": 4,
                "name": "NOEQA2",
                "company": "无设备公司A"
            },
            {
                "lng": 104.183368427163,
                "lat": 30.6917656167707,
                "id": 5,
                "name": "NOEQA2",
                "company": "无设备公司A"
            }
        ];
        //创建标注点添加到地图中
        function addMarker(points) {
            //循环建立标注点
            for (var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
                var marker = new BMap.Marker(point); //将点转化成标注点
                map.addOverlay(marker); //将标注点添加到地图上
                //添加监听事件
                (function () {
                    var thePoint = points[i];
                    marker.addEventListener("click",
                        function () {
                            showInfo(this, thePoint);
                        });
                })();
            }
        }

        function showInfo(thisMarker, point) {
            //获取点的信息
            var sContent =
                '<ul style="margin:0 0 5px 0;padding:0.2em 0">' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">id：</span>' + point.id + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">编号：</span>' + point.name + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 80px;display: inline-block;">公司名称：</span>' + point.company + '</li>' +
                '</ul>';
            document.getElementById('code').value = point.name;
            var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
            thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
        }
        //向地图添加控件
        function addMapControl() {
            var scaleControl = new BMap.ScaleControl({
                anchor: BMAP_ANCHOR_BOTTOM_LEFT
            });
            scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
            map.addControl(scaleControl);
            var navControl = new BMap.NavigationControl({
                anchor: BMAP_ANCHOR_TOP_LEFT,
                type: BMAP_NAVIGATION_CONTROL_LARGE
            });
            map.addControl(navControl);
            var overviewControl = new BMap.OverviewMapControl({
                anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                isOpen: true
            });
            map.addControl(overviewControl);
        }
        var map;
        initMap();
    </script>

    <!-- 无设备公司B 管道1 -->
    <script type="text/javascript">
        //创建和初始化地图函数：
        function initMap() {
            createMap(); //创建地图
            setMapEvent(); //设置地图事件
            addMapControl(); //向地图添加控件
            addMapOverlay(); //向地图添加覆盖物
            addMarker(points);
            // openEdit();
            // closeEdit();
        }

        function createMap() {
            map = new BMap.Map("map4");
            map.centerAndZoom(new BMap.Point(104.050791, 30.689824), 19);
            map.enableScrollWheelZoom(true);

            //点击获取坐标值
            var x;
            var y;
            map.addEventListener("click", function (e) {
                var point = new BMap.Point(e.point.lng, e.point.lat);
                addMarker(point);
                x = e.point.lng;
                y = e.point.lat;
                console.log(e.point.lng + "," + e.point.lat); //获取坐标值
                document.getElementById('jd').value = e.point.lng;
                document.getElementById('wd').value = e.point.lat;
            });
            //地图上的连线
            var polyline3 = new BMap.Polyline([
                new BMap.Point(104.050774, 30.68867),
                new BMap.Point(104.050196, 30.689533),
                new BMap.Point(104.052786, 30.689546)

            ], {
                strokeColor: 'green',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            map.addOverlay(polyline3);
        }

        function setMapEvent() {
            map.enableScrollWheelZoom();
            map.enableKeyboard();
            map.enableDragging();
            map.enableDoubleClickZoom();
        }

        function addClickHandler(target, window) {
            target.addEventListener("click", function () {
                target.openInfoWindow(window);
            });
        }

        function addMapOverlay() {
            var markers = [{
                title: "乐度软件",
                imageOffset: {
                    width: 0,
                    height: 3
                },
                position: {
                    lat: 30.689711,
                    lng: 104.050279
                }
            }];
            for (var index = 0; index < markers.length; index++) {
                var point = new BMap.Point(markers[index].position.lng, markers[index].position.lat);
                var marker = new BMap.Marker(point, {
                    icon: new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png", new BMap
                        .Size(20, 25), {
                            imageOffset: new BMap.Size(markers[index].imageOffset.width, markers[index]
                                .imageOffset.height)
                        })
                });
                var label = new BMap.Label(markers[index].title, {
                    offset: new BMap.Size(25, 5)
                });
                var opts = {
                    width: 200,
                    title: markers[index].title,
                    enableMessage: false
                };
                var infoWindow = new BMap.InfoWindow(markers[index].content, opts);
                marker.setLabel(label);
                addClickHandler(marker, infoWindow);
                map.addOverlay(marker);
            };
        }
        //地图上的点
        var points = [{
                "lng": 104.050774,
                "lat": 30.68867,
                "id": 1,
                "name": "NEQB1",
                "company": "无设备公司B"
            },
            {
                "lng": 104.050196,
                "lat": 30.689533,
                "id": 2,
                "name": "NEQB1",
                "company": "无设备公司B"
            },
            {
                "lng": 104.052786,
                "lat": 30.689546,
                "id": 3,
                "name": "NEQB1",
                "company": "无设备公司B"
            }

        ];
        //创建标注点添加到地图中
        function addMarker(points) {
            //循环建立标注点
            for (var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
                var marker = new BMap.Marker(point); //将点转化成标注点
                map.addOverlay(marker); //将标注点添加到地图上
                //添加监听事件
                (function () {
                    var thePoint = points[i];
                    marker.addEventListener("click",
                        function () {
                            showInfo(this, thePoint);
                        });
                })();
            }
        }

        function showInfo(thisMarker, point) {
            //获取点的信息
            var sContent =
                '<ul style="margin:0 0 5px 0;padding:0.2em 0">' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">id：</span>' + point.id + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">编号：</span>' + point.name + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 80px;display: inline-block;">公司名称：</span>' + point.company + '</li>' +
                '</ul>';
            document.getElementById('code').value = point.name;
            var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
            thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
        }
        //向地图添加控件
        function addMapControl() {
            var scaleControl = new BMap.ScaleControl({
                anchor: BMAP_ANCHOR_BOTTOM_LEFT
            });
            scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
            map.addControl(scaleControl);
            var navControl = new BMap.NavigationControl({
                anchor: BMAP_ANCHOR_TOP_LEFT,
                type: BMAP_NAVIGATION_CONTROL_LARGE
            });
            map.addControl(navControl);
            var overviewControl = new BMap.OverviewMapControl({
                anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                isOpen: true
            });
            map.addControl(overviewControl);
        }
        var map;
        initMap();
    </script>
    <!-- 无设备公司B 管道2 -->
    <script type="text/javascript">
        //创建和初始化地图函数：
        function initMap() {
            createMap(); //创建地图
            setMapEvent(); //设置地图事件
            addMapControl(); //向地图添加控件
            addMapOverlay(); //向地图添加覆盖物
            addMarker(points);
            // openEdit();
            // closeEdit();
        }

        function createMap() {
            map = new BMap.Map("map5");
            map.centerAndZoom(new BMap.Point(104.050791, 30.689824), 19);
            map.enableScrollWheelZoom(true);

            //点击获取坐标值
            var x;
            var y;
            map.addEventListener("click", function (e) {
                var point = new BMap.Point(e.point.lng, e.point.lat);
                addMarker(point);
                x = e.point.lng;
                y = e.point.lat;
                console.log(e.point.lng + "," + e.point.lat); //获取坐标值
                document.getElementById('jd').value = e.point.lng;
                document.getElementById('wd').value = e.point.lat;
            });
            //地图上的连线
            var polyline3 = new BMap.Polyline([
                // new BMap.Point(104.050774, 30.68867),
                // new BMap.Point(104.050196, 30.689533),
                // new BMap.Point(104.052786, 30.689546)

            ], {
                strokeColor: 'green',
                strokeWeight: 3,
                strokeOpacity: 0.5
            });
            map.addOverlay(polyline3);
        }

        function setMapEvent() {
            map.enableScrollWheelZoom();
            map.enableKeyboard();
            map.enableDragging();
            map.enableDoubleClickZoom();
        }

        function addClickHandler(target, window) {
            target.addEventListener("click", function () {
                target.openInfoWindow(window);
            });
        }

        function addMapOverlay() {
            var markers = [{
                title: "乐度软件",
                imageOffset: {
                    width: 0,
                    height: 3
                },
                position: {
                    lat: 30.689711,
                    lng: 104.050279
                }
            }];
            for (var index = 0; index < markers.length; index++) {
                var point = new BMap.Point(markers[index].position.lng, markers[index].position.lat);
                var marker = new BMap.Marker(point, {
                    icon: new BMap.Icon("http://api.map.baidu.com/lbsapi/createmap/images/icon.png", new BMap
                        .Size(20, 25), {
                            imageOffset: new BMap.Size(markers[index].imageOffset.width, markers[index]
                                .imageOffset.height)
                        })
                });
                var label = new BMap.Label(markers[index].title, {
                    offset: new BMap.Size(25, 5)
                });
                var opts = {
                    width: 200,
                    title: markers[index].title,
                    enableMessage: false
                };
                var infoWindow = new BMap.InfoWindow(markers[index].content, opts);
                marker.setLabel(label);
                addClickHandler(marker, infoWindow);
                map.addOverlay(marker);
            };
        }
        //地图上的点
        var points = [
            // { "lng": 104.050774, "lat": 30.68867, "id": 1, "name": "NEQB1", "company": "无设备公司B" },
            // { "lng": 104.050196, "lat": 30.689533, "id": 2, "name": "NEQB1", "company": "无设备公司B" },
            // { "lng": 104.052786, "lat": 30.689546, "id": 3, "name": "NEQB1", "company": "无设备公司B" }

        ];
        //创建标注点添加到地图中
        function addMarker(points) {
            //循环建立标注点
            for (var i = 0, pointsLen = points.length; i < pointsLen; i++) {
                var point = new BMap.Point(points[i].lng, points[i].lat); //将标注点转化成地图上的点
                var marker = new BMap.Marker(point); //将点转化成标注点
                map.addOverlay(marker); //将标注点添加到地图上
                mk.enableDragging(); //可拖拽
                //添加监听事件
                (function () {
                    var thePoint = points[i];
                    marker.addEventListener("click",
                        function () {
                            showInfo(this, thePoint);
                        });
                })();
            }
        }

        function showInfo(thisMarker, point) {
            //获取点的信息
            var sContent =
                '<ul style="margin:0 0 5px 0;padding:0.2em 0">' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">id：</span>' + point.id + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span style="width: 50px;display: inline-block;">编号：</span>' + point.name + '</li>' +
                '<li style="line-height: 26px;font-size: 15px;">' +
                '<span id="company_id" style="width: 80px;display: inline-block;">公司名称：</span>' + point.company +
                '</li>' +
                '</ul>';
            document.getElementById('code').value = point.name;
            var infoWindow = new BMap.InfoWindow(sContent); //创建信息窗口对象
            thisMarker.openInfoWindow(infoWindow); //图片加载完后重绘infoWindow
        }
        // 创建标注对象并添加到地图
        var marker = new BMap.Marker(point);
        map.addOverlay(marker);
        marker.enableDragging(); //可拖拽
        marker.addEventListener("dragend", function (e) {
            $('#x').val(e.point.lng);
            $('#y').val(e.point.lat);
        });
        map.addEventListener("tilesloaded", addMarker);

        function addMarker() {
            var x = $("#x").val();
            var y = $("#y").val();
            if (x != '' && y != '') {
                map.panTo(new BMap.Point(x, y));
                map.setZoom(18);
                var point = new BMap.Point(x, y); //默认
                // 创建标注对象并添加到地图
                var marker = new BMap.Marker(point);
                map.addOverlay(marker);
                marker.enableDragging(); //可拖拽
                marker.addEventListener("dragend", function (e) {
                    $('#x').val(e.point.lng);
                    $('#y').val(e.point.lat);
                });
            }
            map.removeEventListener("tilesloaded", addMarker);
        }
        //向地图添加控件
        function addMapControl() {
            var scaleControl = new BMap.ScaleControl({
                anchor: BMAP_ANCHOR_BOTTOM_LEFT
            });
            scaleControl.setUnit(BMAP_UNIT_IMPERIAL);
            map.addControl(scaleControl);
            var navControl = new BMap.NavigationControl({
                anchor: BMAP_ANCHOR_TOP_LEFT,
                type: BMAP_NAVIGATION_CONTROL_LARGE
            });
            map.addControl(navControl);
            var overviewControl = new BMap.OverviewMapControl({
                anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                isOpen: true
            });
            map.addControl(overviewControl);
        }
        var map;
        initMap();
    </script>
    <script type="text/javascript">
        //初始化获取所有检测数据
        $(function () {
            $.ajax({
                type: "post",
                data: {
                    business_id: $("#business_id").val(),
                    type: 'all'
                },
                url: "{:url('Checklog/ajax_get_pipeinfo')}",
                dataType: "json",
                success: function (res) {
                    console.debug(res);
                    if (res.code) {
                        //获取到数据
                        var sort_info = res.data.sort_info; //检测点数据
                    }
                }
            });
        });
        //公司筛选框变动获取公司下所有管道的检测点,和管道数据用作拼接管道筛选框
        $("#company_id").on('change', function () {
            $.ajax({
                type: "post",
                data: {
                    business_id: $("#business_id").val(),
                    company_id: $("#company_id").val(),
                    type: 'company'
                },
                url: "{:url('Checklog/ajax_get_pipeinfo')}",
                dataType: "json",
                success: function (res) {
                    if (res.code) {
                        var pipeline_info = res.data.pipeline_info; //管道数据
                        var sort_info = res.data.sort_info; //检测点数据
                        //获取到数据
                    }
                }
            });
        });
        //管道筛选框获取选择管道的检测点
        $("#pipeline_number").on('change', function () {
            $.ajax({
                type: "post",
                data: {
                    business_id: $("#business_id").val(),
                    company_id: $("#company_id").val(),
                    pipeline_number: $("#pipeline_number").val(),
                    type: 'pipeline'
                },
                url: "{:url('Checklog/ajax_get_pipeinfo')}",
                dataType: "json",
                success: function (res) {
                    if (res.code) {
                        //获取到数据
                        var sort_info = res.data.sort_info; //检测点数据
                    }

                }
            });
        })
    </script>

    {/block}